<template>
  <div class="bg flex flex-align-center">
    <el-form 
      class="color-white ml100"
      label-position="top"
      label-width="100px"
      :model="form"
      :rules="rules"
      ref="loginForm"
      style="max-width: 460px">


      <el-form-item label="手机号" prop="phone">
        <el-input v-model="form.phone"></el-input>
      </el-form-item>

      <el-form-item label="密码" prop="password">
        <el-input type="password" show-password v-model="form.password"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit()" >登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        phone: '',
        password: ''
      },
      rules: {
        phone: [
          { required: true,message: '请输入手机号', trigger: 'blur' },
          { validator: this.validatePhone, trigger: 'blur' }
        ],
        password: [
          { required: true,message: '请输入密码', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    validatePhone (rule,value,callback) {
      let regex = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/
      let result = regex.test(value)
      if (result) {
        callback()
      }else{
        callback(new Error('请输入正确的手机号格式'))
      }
      
    },
    submit () {
      this.$refs.loginForm.validate((result)=>{
        // 发起后端请求 密码加密
        // 已经收到了后端的响应，成功 
        
        

      })
    }
  }
}
</script>

<style scoped>
.bg >>> .el-form-item__label{
  color: #d5d5d5;
  font-size: 13px;
 }
</style>


<style lang="less" scoped>
 
 .bg{
  height: 100vh;
  background: url(./../../assets/bg2.webp);
  background-size: contain;
  /deep/ 
    .el-input__wrapper{
      background: none;
      box-shadow: none;
      border-bottom: 1px solid #d5d5d5;
    }
  }
</style>